﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Medianamik.Core;
using Telerik.Web.UI;
using Medianamik.UI.Controls;
using Medianamik.UI.Lock;

namespace Medianamik.UI.ConfigManagement
{
    public partial class DomainList : BaseModuleListPage
    {
        protected void btnNodeActivation_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName.ToLowerInvariant() == "deactivate")
            {
                NodeManager.SetNodeActiveStatus(new Guid((string)e.CommandArgument), CurrentEditionCulture, false);
            }
            else if (e.CommandName.ToLowerInvariant() == "activate")
            {
                NodeManager.SetNodeActiveStatus(new Guid((string)e.CommandArgument), CurrentEditionCulture, true);
            }

            Grid.Rebind();
        }

        protected override void GridNeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            domainGrid.DataSource = ConfigManager.GetAll<Domain>(CurrentUICulture)
                 .OrderBy(m => m.Position);
        }

        protected override RadGrid Grid
        {
            get { return domainGrid; }
        }

        protected override UpdatePanel GridUpdatePanel
        {
            get { return mainUpdatePanel; }
        }

        protected override string ManagementURL
        {
            get { return "domainmanagement.aspx"; }
        }

        protected override bool DestroyOnDelete
        {
            get { return true; }
        }

        protected override bool EnableSorting
        {
            get { return true; }
        }

        protected override string ReturnUrl
        {
            get { return "/medianamik/configmanagement/domainlist.aspx"; }
        }
    }
}
